home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
basdlx12.arc
/
BASDLX.DOC
next >
Wrap
Text File
|
1987-02-03
|
21KB
|
661 lines
BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 1
BASDLX.LIB
Deluxe Library of functions written in assembly language for the
BASIC Compiler
BASDLX, Basic Deluxe, is a library of powerful functions for com-
piled BASIC. To use BASDLX.LIB you will need, either the IBM
Basic compiler or the Microsoft Quickbasic compiler. I suggest
that you use PC-DOS/MS-DOS versions 2.0 or later to insure full
compatibility. These routines have been tested with the IBM Basic
compiler version 2.0 and have caused no problems. However, I am
not responsible for any damages caused by but, not limited to,
the use, misuse or inability to use BASDLX. These deluxe func-
tions are intended to be used in compiled basic only. Do not con-
fuse compiled BASIC with the BASIC interpreter, BASIC.COM or
BASICA.COM that comes with DOS. The functions provided in this
library have been designed to run faster than it's correspondent
basic code, and often take up less space, leaving you with more
room to write longer programs!
This is the Second, of many public releases of the Basic Deluxe
library. You are free to use the functions provided in the BASDLX
library in your programs. The copyright is only here to preserve
my work and to protect you from any unauthorized modifications of
BASDLX; it is NOT here to protect against the free distribution
of BASDLX. You may copy and distribute BASDLX to others as long
as no fee or special consideration is charged and all of the re-
lated files to BASDLX are included together in the unmodified
form. If you use BASDLX in your programs and find it a valuable
tool then I would appreciate it if you would send a contribution
($25 suggested). It would be nice if you could acknowledge use
of BASDLX functions in your programs or documentation that use
them. Your contribution will go into a fund that will finance the
rental of a private BBS for contributors. Your privileges on
this system will include: 50 minutes of access time per day, and
a special on-line "BASDLX Request/Comment Form" where you may
request new functions, or comment on existing ones! You will also
be able to download the latest version of BASDLX, including the
source code.
These routines have been incorporated into a library to make them
easily accessible by the DOS LINK.EXE program. All you have to
do is copy BASDLX.LIB to the directory or disk where you keep
your library files. When you link your programs that use func-
tions from BASDLX, be sure to specify: BASDLX when the linker
prompts you for a Library [.LIB] file(s). Please refer to your
DOS manual for more information on the LINK.EXE program.
--- BASDLX Version 1.2 February 1987 ---
BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 2
Special Notes
The functions provided in this library are available to you by
using the CALL command from compiled basic. All numeric variables
passed as arguments to the functions must defined as integers.
This means that you can either globally set all numeric variables
to integers by issuing the DEFINT A-Z command at the beginning of
your program or, you can declare a single variable as integer by
adding a "%" symbol at the end of its name. (i.e. I%, this will
declare the variable as being integer). I will always add the "%"
symbol at the end of all my numeric variables in all of my ex-
amples, to remind you that they MUST be integers.
The variable names used in my examples don't have to be exactly
the same. you may choose other names that would be more ap-
propriate. keep in mind that the variable types do have to be the
same in the argument list (i.e. strings must be strings, integers
must be integers).
As I mentioned before I have tested these functions and they, to
the best of my knowledge, work bug free. But, if you happen to
find any bugs I'll be happy to fix them. Be sure to check that
you are CALLing the functions properly. That is that you are
sending the correct arguments to the function. One of the most
common error that occurs is when the calling program sends to
the function an incorrect variable type. Remember that numeric
variables must be declared integer.
Since this is the second of many releases of BASDLX I'm sure I
will get a lot of comments from you. So please don't hesitate to
inform me of anything! If there is something you don't like about
BASDLX then please don't refrain from telling me, I'll be more
than happy to fix it!
Please refer any questions, comments, requests for new routines
or contributions to the following address:
Gustavo H. Verdun
6424 Hollins Drive
Bethesda, MD 20817
--- BASDLX Version 1.2 February 1987 ---
BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 3
Function Name: BSORTN
Arguments : (Num_of_elements,Integer_array%(start))
type : integer array service
Purpose : Sorts an integer array in ascending order with
negative numbers appearing at the end in
ascending order.
Description:
Integer variables in BASIC can contain numbers between -32,768
and 32,767. This function does not distinguish between negative
or positive numbers. It will sort the elements in ascending order
with all the negative numbers (if existing) appearing after the
positive numbers in ascending order. Make sure that the array is
of type integer. Unpredictable results may occur if not!
Example:
dim a%(300):print "Array Before sort:"
for i%=0 to 300:a%(i%)=int(rnd(1)*30000):print a%(i%),:next
enum%=301:call bsortn(enum%,a%(0))
rem enum%=301 because there are 301 elements in the array (0-300)
print "Array After sort:":for i%=0 to 300:print a%(i%),:next
rem the list should be sorted in ascending numerical order!
Function Name: BSORTS
Arguments : (Num_of_elements%,Array$(start_position))
Type : String array service
Purpose : Sorts a string array in ascending alphabetical
order.
Description:
The first argument should contain the number of elements to sort
in the array. The second argument is the array itself. be sure to
specify the starting position in the array [i.e.
BSORTS(elements%,a$(0))]
IMPORTANT: All of the elements in the array MUST have equal
lengths, if not, unpredictable results will occur to BASIC
Example:
dim a$(10):a$(0)"First":a$(1)="Second":a$(2)="Third"
a$(3)="Fourth":a$(4)="Fifth":a$(5)="Sixth":a$(6)="Seventh"
a$(7)="Eighth":a$(8)="Ninth":a$(9)="Tenth"
for i%=0 to 9:b$=space$(10):call setl(a$(i%),b$):a$(i%)=b$:next
rem the above line will make all of the elements in the array
rem have equal lengths.
print "Array before sort:":for i%=0 to 9:print a$(i%):next
enum%=10:call bsorts(enum%,a$(0))
rem enum%=10 because there are 10 elements in the array (0-9)
print "Array After sort:":for i%=0 to 9:print a$(i%):next
rem the list should be sorted in ascending alphabetical order!
--- BASDLX Version 1.2 February 1987 ---
BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 4
Function Name: GUN
Arguments : (Num_of_shots%)
Type : Speaker support
Purpose : Simulates the sound of a gun or machine gun
Description :
This function generates the sound by sending spurts of white
noise to the speaker. This will create the sound of a quick ex-
plosion. the only parameter needed is the number of shots to
fire.
Example:
input "Number of shots to fire :",shots%:if shots%=0 then end
call gun(shots%)
--- BASDLX Version 1.2 February 1987 ---
BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 5
Function Name: READP
Arguments : (Port_num%)
Type : Printer support
Purpose : Reads the printer status of the specified port
number (1-3) and returns with the status byte
for that port in the port_num% variable.
Description:
The status byte of contains the following information:
bit: 7 6 5 4 3 2-1 0
| | | | | | |_Time out
| | | | | |_Unused
| | | | |_1 = I/O Error
| | | |_1 = Selected
| | |_1 = Out of Paper
| |_1 = Acknowledge
|_1 = Not Busy
IMPORTANT: This routine does not check for a valid port number.
Be sure that the port number is in the range of 1-3
Example:
port%=1:call readp(port%):print port%
if port% and 32=32 then print "Printer is out of paper"
if port% and 128=0 then print "Printer is Off-line"
Function Name: RESETP
Arguments : (Port_num%)
Type : Printer support
Purpose : Resets the specified printer port number (1-3)
and returns with its status byte (see the READP
function description for information on the
printer status byte)
Description:
This function sends a reset status through the parallel inter-
face of the specified port number. This routine does check the
parameters to be sure that they are in the range of 1 to 3. If
the port_num% argument is equal to -1 upon return then the port
number is not valid.
Example:
port%=1:call resetp(port%):print port%
if port%=-1 then print"Port number must be in the range of 1-3"
if port% and 32=32 then print "Printer is out of paper"
if port% and 128=0 then print "Printer is Off-line"
--- BASDLX Version 1.2 February 1987 ---
BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 6
Function Name: SETL
Arguments : (Source_string$,Destination_string$)
Type : String manipulation
Purpose : This function will place the source string inside
of the destination left-justified. If the source
string is longer than the destination string then
the right portion of the string will be truncated.
Description:
This function automatically sets the destination string to spaces
(ASCII 32) even if the source string is of length zero. Be sure
to save the destination string into the source string after the
function call.
Example:
a$="Enter Name":b$=space(20):call setl(a$,b$):a$=b$
rem the last command "a$=b$" saves the destination string in the
rem source string since the function cant' change the length of
rem any string.
print ">";a$";"<":REM this will show you the new length of a$
Function Name: SETR
Arguments : (Source_string$,Destination_string$)
Type : String manipulation
Purpose : This function will place the source string inside
the destination string right justified. If the
destination string is shorter than the source
string then the right portion of the string will
be truncated.
Description:
This function automatically sets the destination string to all
spaces (ASCII 32) even if the source string is of length zero. Be
sure to save the destination string into the source string after
the function call.
Example:
a$="Enter Name":b$=space(20):call setr(a$,b$):a$=b$
rem the last command "a$=b$" saves the destination string in the
rem source string since the function cant' change the length of
rem any string.
print ">";a$;"<":REM this will show you the new length of a$
--- BASDLX Version 1.2 February 1987 ---
BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 7
Function Name: SNDOFF
Arguments : NONE
Type : Speaker support
Purpose : Turns speaker off. If this function is used then
the BASIC SOUND or BEEP commands will not work.
Description :
This function can be useful for those programs that use sound
prompts to get attention when input is required. With this func-
tion you can easily add the feature to your programs that will
let the user decide if he wants to have the sound prompts on or
off. If he wants the off then at the beginning of your program
just call this function. Any sound statements following this com-
mand will execute without producing a single sound. Be sure not
to forget to turn them on before the program finishes (SNDON).
Example :
sound 200,1:sound 300,1:sound 400,1:call sndoff
sound 200,1:sound 300,1:sound 400,1
Function Name: SNDON
Arguments : NONE
Type : Speaker support
Purpose : Turns sound on so that the BASIC SOUND and BEEP
commands work.
Description:
This function can help solve the problem that occurs when you use
some memory resident programs that use the speaker and when they
are done the turn it off so that any SOUND or BEEP commands won't
produce an audible signal. It can also turn on the sound when it
was turned off by the function SNDOFF!
Example:
sound 200,1:sound 300,1:sound 400,1:call sndoff
sound 200,1:sound 300,1:sound 400,1:call sndon
sound 200,1:sound 300,1:sound 400,1
--- BASDLX Version 1.2 February 1987 ---
BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 8
Function Name: XLC
Arguments : (String$)
Type : String manipulation
Purpose : Converts the string to lower case.
Description:
No further explanations are necessary, I hope!
Example:
a="THIS WILL BE IN LOWER CASE!":call xlc(a$):print a$
Function Name: XUC
Arguments : (String$)
Type : String manipulation
Purpose : Converts the string to upper case.
Description:
No further explanations are necessary, I hope!
Example:
a="this will be in upper case!":call xuc(a$):print a$
--- BASDLX Version 1.2 February 1987 ---
BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 9
Summary of Functions
Please use this as a quick summary to BASDLX functions. This sum-
mary should only be used once you understand the routines, but
just need a quick refreshment.
Function Name: BSORTN
Arguments : (Num_of_elements,Integer_array%(start))
type : integer variable service
Purpose : Sorts an integer array in ascending order with
negative numbers appearing at the end in
ascending order.
Function Name: BSORTS
Arguments : (Num_of_elements%,Array$(start_position))
Type : String service
Purpose : Sorts a string array in ascending alphabetical
order.
Function Name: GUN
Arguments : (Num_of_shots%)
Type : Speaker support
Purpose : Simulates the sound of a gun or machine gun
Function Name: READP
Arguments : (Port_num%)
Type : Printer support
Purpose : Reads the printer status of the specified port
number (1-3) and returns with the status byte
for that port in the port_num% variable.
Function Name: RESETP
Arguments : (Port_num%)
Type : Printer support
Purpose : Resets the specified printer port number (1-3)
and returns with its status byte (see the READP
function description for information on the
printer status byte)
Function Name: SETL
Arguments : (Source_string$,Destination_string$)
Type : String manipulation
Purpose : This function will place the source string inside
of the destination left-justified. If the source
string is longer than the destination string then
the right portion of the string will be truncated.
--- BASDLX Version 1.2 February 1987 ---
BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 10
Summary of Functions (Cont.)
Function Name: SETR
Arguments : (Source_string$,Destination_string$)
Type : String manipulation
Purpose : This function will place the source string inside
the destination string right justified. If the
destination string is shorter than the source
string then the right portion of the string will
be truncated.
Function Name: SNDOFF
Arguments : NONE
Type : Speaker support
Purpose : Turns speaker off. If this function is used then
the BASIC SOUND or BEEP commands will not work.
Function Name: SNDON
Arguments : NONE
Type : Speaker support
Purpose : Turns sound on so that the BASIC SOUND and BEEP
commands work.
Function Name: XLC
Arguments : (String$)
Type : String manipulation
Purpose : Converts the string to lower case.
Function Name: XUC
Arguments : (String$)
Type : String manipulation
Purpose : Converts the string to upper case.
--- BASDLX Version 1.2 February 1987 ---
BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 11
--- BASDLX Version 1.2 February 1987 ---